package com.starinside.wp.domain.course;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.starinside.wp.domain.Domain;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;

/**
 * 课程，以区别于原系统内course
 * 例如：一年级语文，第一节课。
 */
@Table(name = "tc_vendor_course")
@Data
@EqualsAndHashCode(callSuper = true)
@Entity
public class VendorCourse extends Domain implements Serializable {
    private static final long serialVersionUID = 1L;

    @Column(name = "id")
    private String id;

    @JsonIgnore
    @Column(name = "published")
    private Boolean published = Boolean.FALSE;

    @Column(name = "title", nullable = false)
    private String title;

    @Column(columnDefinition = "varchar(255)   COMMENT '封面' ")
    private String cover;

    @JsonIgnore
    @Column(name = "topic_id", nullable = false)
    private String topicId;

    @OneToOne
    @JoinColumn(name = "topic_id", insertable = false, updatable = false)
    private VendorCourseTopic topic;

    @Column(name = "course_package_id")
    private String coursePackageId;

    @Column(name = "author")
    private String author;

    @Column(name = "age")
    private String age;

    //即厂商 id
    @Column(name = "authorId")
    private String authorId;

    //最后更新时间
    @Column(name = "last_updated")
    private Timestamp lastUpdated;

    /**
     * 附件列表JSON [{ "name":"", "type":"",url:""}]
     */
    @Column(name = "attachments")
    private String attachments;

    /**
     * 教具列表 [{"name":"积木","number":"6","img":"https://tuo51-course.oss-cn-beijing.aliyuncs.com/teach/file/attachments/file/1/1604048278209.png","unit":"块","type":"老师"}]
     */
    @Column(name = "tools")
    private String tools;

    //标签  例如：基础，火热，促销，重点  等。
    @Column(name = "label")
    private String label;

    //课程包的名字，例如  一年级语文
    @Column(name = "package_name")
    private String packageName;

    /**
     * 课程包里的序号，课程编码
     */
    @Column(name = "index_in_package")
    private Integer indexInPackage = 0;

    //标签，竖线分割
    @Column(name = "tags")
    private String tags;

    /**
     * 教学提升领域，竖线分割
     */
    @Column(name = "dimensions")
    private String dimensions;

    /**
     * 教学指导文字版
     */
    @Column(name = "guideText")
    private String guideText;

    //示范课视频地址
    @Column(name = "guideVideo")
    private String guideVideo;

    /**
     * 内容
     */
    @Column(name = "content", nullable = false)
    private String content;


    /**
     * 备注
     */
    @Column(name = "comment")
    private String comment;

    /**
     * 关联书籍
     */
    @Column(name = "ref_books")
    private String refBooks;

    //关联视频地址，竖线分割
    @Column(name = "videourl")
    private String videourl;

    //使用过的模板 id，仅供参考，因为模板可能会被编辑
    @JsonIgnore
    @Column(name = "content_template_id", nullable = false)
    private String contentTemplateId;

    //混合有模板与数据的 JSON 字符串，编辑的时候以实际内容做编辑
    //[{"name":"引起动机"，"type":"text", "content":""}, {"name":"主体活动", "type":"richtext"}, {"name":"反馈活动", "type":"attachments"}]
    @Column(name = "content_template", columnDefinition = "varchar(2048) COMMENT '当前模板'", nullable = false)
    private String contentTemplate;

    @Column(columnDefinition = "text   COMMENT '课程详情' ")
    private String  details;

    /**
     * 课程分类
     */
    @Column(columnDefinition = "varchar(64)   COMMENT '课程分类' ")
    private String sort;


    @Column(columnDefinition = "varchar(255)   COMMENT '时长（分钟）' ")
    private String durations;

    @Column(columnDefinition = "varchar(32)  COMMENT '创建人'")
    private String createdBy;

    @Column(columnDefinition = "varchar(255)  COMMENT '创建人名称'")
    private String createdName;

    /**
     * 月龄 低限
     */
    @Column(columnDefinition = " int DEFAULT 0 COMMENT ' 月龄 低限 ' ")
    private Integer ageLow;

    /**
     * 月龄 高限
     */
    @Column(columnDefinition = " int DEFAULT 0 COMMENT ' 月龄 高限 ' ")
    private Integer ageHigh;


    @Column(columnDefinition = " int DEFAULT 0 COMMENT ' 类型' ")
    private Integer type;
}